/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements.  See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License.  You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/


/*************************************************************************
 *\author: starlove
 *************************************************************************/
#ifndef __CC_PYTHON_IMPORT_O_ATLASNODE_IMPL__
#define __CC_PYTHON_IMPORT_O_ATLASNODE_IMPL__

#include "python_object_atlasnode.h"
#include "python_object_texture2d.h"

NS_CCPY_BEGIN
	CCNODE_OBJECT_WRAPPER_IMPL(CCAtlasNode, CPyAtlasNode)	

	PYCLASS_INIT_AND_BASE_2(CPyAtlasNode, CPyNodeRGBA, CPyTextureProtocol, "CCAtlasNode", "Python CCAtlasNode Object");
	PYCLASS_BEGIN_METHOD_DEF(CPyAtlasNode)
	PYCLASS_ADD_METHOD(CPyAtlasNode, initWithTileFile)
	PYCLASS_ADD_METHOD(CPyAtlasNode, initWithTexture)
	PYCLASS_ADD_METHOD(CPyAtlasNode, updateAtlasValues)
	PYCLASS_END_METHOD_DEF(CPyAtlasNode)
	PYCLASS_BEGIN_GETSET_DEF(CPyAtlasNode)
	PYCLASS_END_GETSET_DEF(CPyAtlasNode)
	PYCLASS_IMP_INTERFACE_NOINIT(CPyAtlasNode)

	int CPyAtlasNode::__init__(CPyAtlasNode *pySelf, PyObject *pyArgs, PyObject *pyKW)
	{
		if( !pyArgs )
			return 0;
		static char* kwlist[] = {"tile", "tileWidth", "tileHeight", "itemsToRender", NULL};
		char *tile = "";
		unsigned int tileWidth = 0;
		unsigned int tileHeight = 0;
		unsigned int itemsToRender = 0;
		if(!PyArg_ParseTupleAndKeywords(pyArgs,pyKW,"sIII",kwlist, &tile, &tileWidth, &tileHeight, &itemsToRender))
			return 0;
		CC_METHOD_WRAPPER_GETER_RINT(cocos2d::CCAtlasNode *, CPyAtlasNode, initWithTileFile, bool, tile, tileWidth, tileHeight, itemsToRender);
		return 0;
	}
	
	PYCLASS_METHOD_IMPL(CPyAtlasNode, initWithTileFile)
	{
		char *tile = "";
		unsigned int tileWidth = 0;
		unsigned int tileHeight = 0;
		unsigned int itemsToRender = 0;
		if( !PyArg_ParseTuple(pyArgs, "sIII", &tile, &tileWidth, &tileHeight, &itemsToRender) )
			Py_RETURN_FALSE;
		CC_METHOD_WRAPPER_GETER(cocos2d::CCAtlasNode *, CPyAtlasNode, initWithTileFile, bool, tile, tileWidth, tileHeight, itemsToRender);
		Py_RETURN_BOOL(v);
	}

	PYCLASS_METHOD_IMPL(CPyAtlasNode, initWithTexture)
	{
		PyObject *tex = NULL;
		unsigned int tileWidth = 0;
		unsigned int tileHeight = 0;
		unsigned int itemsToRender = 0;
		if( !PyArg_ParseTuple(pyArgs, "OIII", &tex, &tileWidth, &tileHeight, &itemsToRender) )
			Py_RETURN_FALSE;		
		if(!tex || !PyObject_TypeCheck(tex, CPyClassBase::GetTypeObject<CPyTexture2D>()))
			Py_RETURN_FALSE;
		CPyTexture2D *ptex = (CPyTexture2D *)tex;
		CC_METHOD_WRAPPER_GETER(cocos2d::CCAtlasNode *, CPyAtlasNode, initWithTexture, bool, (cocos2d::CCTexture2D *)ptex->getCCObject(), tileWidth, tileHeight, itemsToRender);
		Py_RETURN_BOOL(v);
	}

	PYCLASS_METHOD_IMPL(CPyAtlasNode, updateAtlasValues)
	{
		CC_METHOD_WRAPPER_SETER(cocos2d::CCAtlasNode *, CPyAtlasNode, updateAtlasValues);
		Py_RETURN_NONE;
	}
	
NS_CCPY_END

#endif